package com.kaifamiao.time;

import java.time.LocalTime;
import java.time.LocalTime;

/**
 * 1、LocalTime 类重写了从 Object 继承的 equals(Object)
 * 2、boolean isBefore( LocalTime other )
 * 3、boolean isAfter( LocalTime other )
 * 4、int compareTo( LocalTime other )
 */
public class CompareLocalTime {

    public static void main(String[] args) {
        LocalTime first = LocalTime.of( 11, 45, 0 );
        LocalTime second = LocalTime.of( 11 , 45 , 0 );
        System.out.println( first == second ); // false
        System.out.println( first.equals( second ) ); // true

        System.out.println( "- - - - -" );

        LocalTime third = LocalTime.of( 12 , 30 , 45 );
        System.out.println( first.isBefore( third ) ); // true
        System.out.println( first.isAfter( third ) ); // false

        System.out.println( third.isAfter( first ) ); // true
        System.out.println( third.isBefore( first ) ); // false

        System.out.println( "- - - - -" );

        System.out.println( first.compareTo( third ) ); // 负整数
        System.out.println( first.compareTo( second ) ); // 零
        System.out.println( third.compareTo( first ) ); // 正整数

    }

}
